import uniFetch from './uni-fetch.js'

/**
 * 任务列表
 * @param {number} status - 任务状态
 * @param {string} page - 数据页码
 * @param {string} pageSize - 每页数据数量
 */
export const getPickUpListApi = (status, page = 1, pageSize = 10) => {
  if (!status) return
  return uniFetch.get('/driver/tasks/list', { status, page, pageSize })
}

/**
 * 获取任务详情
 */
export const getTaskDetailApi = (id) => {
  if (!id) return
  return uniFetch.get(`/driver/tasks/details/${id}`)
}

/**
 * 延迟提货
 */
export const delayApi = (data) => {
  if (!data.id) return
  return uniFetch.put('/driver/tasks/delay', data)
}

/**
 * 提货
 */
export const pickupApi = (data) => {
  if (!data.id) return
  return uniFetch.post('/driver/tasks/takeDelivery', data)
}

/**
 * 上报异常
 */
export const exceptionApi = (data) => {
  if (!data.transportTaskId) return
  return uniFetch.post('/driver/tasks/reportException', data)
}

/**
 * 交付
 * @property {Object} data - 接口参数
 */
export const deliverApi = (data) => {
  if (!data.id) return
  return uniFetch.post('/driver/tasks/deliver', data)
}

/**
 * 回车登记
 */
export const truckApi = (data) => {
  if (!data.id) return
  return uniFetch.post('/driver/tasks/truckRegistration', data)
}
